<?php

class ResourcesType {
	private $id;
	private $description;
	
	function __construct($id,$description){
		$this -> id 			= $id;
		$this -> description 	= $description;
	}
	
	function getResourcesType($db,$id){
		$result			= $db->query("SELECT * FROM resources_type WHERE rt_IDtype = $id",2);
		$resourcesType 	= new ResourcesType(	
							$result[0]['rt_IDtype'],
							$result[0]['rt_description']);
		return $resourcesType;
	}
	
	function getList($db){
		$result=$db->query("SELECT * FROM resources_type",2);
		return $result;
	}
	
	function insert($db,$resourcesType){
		$description 	= $resourcesType -> getDescription();
		$result			= $db -> insert("INSERT INTO resources_type (rt_description)
										 VALUES('".addslashes(utf8_decode($description))."')");
		return $result;
	}

	function delete($db,$resourcesType){
		$id 	= $resourcesType -> getIDresourcesType();
		$result = $db -> delete("DELETE FROM resources_type WHERE rt_IDtype = $id");
		return $result;
	}

	function update($db,$resourcesType){
		$id 			= $resourcesType -> getIDresourcesType();
		$description 	= $resourcesType -> getDescription();
		$result = $db -> update ("UPDATE resources_type SET rt_description 	= '".addslashes(utf8_decode($description))."'
													  WHERE rt_IDtype = $id");
		return $result;
	}
	

	function getIDresourcesType(){
		return $this -> id;
	}	
	function setIDresourcesType($id){
		$this -> id = $id;
	}	

	function getDescription(){
		return $this -> description;
	}
	function  setDescription($description){
		$this -> description = $description;
	}
}

?>